<template>
  <iframe v-if="pdfview" :src="pdfview" style="width: 100%;height: 100%; border: 0"></iframe>
</template>

<script>
import { ref, watch } from 'vue'
import pdf from '@/app/pdf'

export default {
  props: ['view'],
  emits: ['over'],
  setup(props, { emit }) {
    const pdfview = ref()

    // 监听更改
    watch(() => props.view, () => {
      // 渲染pdf
      const pdfdoc = pdf.load(props.view)
      pdfdoc.data().then(res => {
        pdfview.value = res
        emit('over')
      })
    })
    
    return {
      pdfview
    }
  }
}
</script>